package common;

import java.util.concurrent.TimeUnit;

public class Bid extends Auction {

	private static final long serialVersionUID = 1L;

	public Bid( String owner, Commodity commodity, double price, int quantity, long duration, TimeUnit time) {
		super( owner, commodity, price, quantity, duration, time);
	}

	public boolean isValid(double d, int quantity) {
		return !invalidCommodity() && !invalidBidPrice( d ) && !overQuantity( quantity ) && this.quantity > 0;
	}
	public boolean isValid(CommodityLimits L) {
		return (L.isBuyer && isValid(L.bound, L.quota));
	}
	public boolean isValidMatch(Auction a) {
		return (a.quantity == super.quantity && price >= a.price); 
	}
	
	public boolean invalidBidPrice( double d ) {
		return super.price <= 0 || super.price > d;
	}
	

	
	public String toString() {
		return "Bid  \t"+super.toString();
	}

	public String getType() {
		return "Bid";
	}
}
